home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DLLCust_Files / LINAXON / BKGAINTA.C next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  943 b   |  29 lines

  1. // Dynamic link library implementation of BackTanhAxon with user gain control
  2.  
  3. #include "NSDLL.h"
  4.  
  5. /********************************/
  6. /* Backpropagation of component */
  7.  
  8. __declspec(dllexport) void performBackLinearAxon(
  9.     DLLData    *instance,        // Pointer to instance data
  10.     DLLData    *dualInstance,        // Pointer to the forward axons instance data
  11.     NSFloat    *data,             // Pointer to the layer of processing elements (PEs)
  12.     int     rows,            // Number of rows of PEs in the layer
  13.     int     cols,            // Number of columns of PEs in the layer
  14.     NSFloat    *error,         // Pointer to the sensitivity vector
  15.     NSFloat    *gradient,         // Pointer to the bias gradient vector
  16.     NSFloat    beta            // Slope gain scalar, same for all PEs
  17.     )
  18.     
  19. {
  20.     int i, length=rows*cols;
  21.     NSFloat gain = getFloatParameter(dualInstance, 2, 1);
  22.  
  23.     for (i=0; i<length; i++) {
  24.         error[i] *= gain*beta*(1.0f - data[i]*data[i] + 0.1f);
  25.         if (gradient)
  26.             gradient[i] += error[i];
  27.     } 
  28. }
  29.